/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package net.flowas.secure;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
//import javax.enterprise.context.SessionScoped;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
//import net.flowas.catchexception.ValidationInterceptorBinding;
//import net.flowas.materialbilling.domain.OrderForm;
import net.flowas.secure.entity.Group;
import net.flowas.secure.entity.User;
//import org.apache.shiro.SecurityUtils;
//import org.apache.shiro.authc.AuthenticationToken;
//import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * REST Web Service
 *
 * @author Administrator
 */
@Path("acountInfo")
//@SessionScoped
public class AcountInfoResource implements Serializable {

    private Map<String, Object> alias=new HashMap<String,Object>();
        
    @GET
    @Path("{modelType}")
    @Produces("application/json")
    public Map<String, Object> constructSettings(@PathParam("modelType") String modelType) {        
        if("OrderForm".equals(modelType)){
            /*OrderForm of=new OrderForm();
            Position p=new Position();
            Group g=new Group();
            g.setId(2L);
            p.setDepartment(g);
            of.setPosition(p);
            alias.put("currentItem", of);*/
        }
        return alias;
    }
     
    @PUT
    @Path("login")
    @Consumes("application/json")
    @Produces("application/json")
    //@ValidationInterceptorBinding
    public void login(Credential entity) {
        //AuthenticationToken authenticationToken=new UsernamePasswordToken(entity.getUsername(), entity.getPassword());
        //SecurityUtils.getSubject().login(authenticationToken);
        alias.put("operateDate", entity.getOperateDate());
        alias.put("username", entity.getUsername());
        //User userObj = (User) SecurityUtils.getSubject().getPrincipal();
        Map<String, Object> currentItem=new HashMap<String,Object>();
        Map<String, Object> group=new HashMap<String,Object>(); 
        //group.put("id", userObj.getGroup().getId());
        currentItem.put("group", group);
        //alias.put("currentItem", currentItem);
        alias.put("group", group);
        //SecurityUtils.getSubject().checkPermission("hello");
    }
}
